-- die_drop_fruits
-- created by zhuangsl
-- 死亡掉落果实(多次)

return {
    apply = function(prop, baseValue)
        return baseValue + prop[3];
    end,

    -- 死亡触发
    trigger = function(who, prop, arg)
        if who.type ~= OBJECT_TYPE_MONSTER then
            return;
        end

        local amount = 1;
        local add = prop[3] - 1;
        assert(add >= 0);
        
        local dropNum  = tonumber(prop[2]);

        -- 设置奖励
        local class = DungeonM.getClassByType(GRID_TYPE_ITEM);
        local pos = who:getPos();
        
        -- 多次掉落
        for i = 1, dropNum do
            -- 数量
            amount = 1 + i % (add + 1);
            -- 找个空位
            pos = SummonM.findSummonPos(pos);

            if pos <= 0 then
                -- 没有空格了就不掉了
                return;
            end
            
            DungeonM.transformGrid(class, pos, GRID_STATE_OPEN, {["bonus"] = {1, 1110, amount}, });
        end

        return true;
    end,

    record = function(target, prop, path)
        return false;
    end
};
